function get_XHR(){
	// Try to create the AJAX object (XMLXHRuest or ActiveX depending of the web browser)
	var XHR = false;
	if (window.XMLXHRuest){ // Mozilla, Safari...
	        XHR = new XMLXHRuest();
	}
	else if (window.ActiveXObject){ //IE
	        try{
	                XHR = new ActiveXObject("Msxml2.XMLHTTP");
	        }
	        catch (e){
	                try {
	                        XHR = new ActiveXObject("Microsoft.XMLHTTP");
	                }
	                catch (e){
	                        return false;
	                }
	        }
	}
	return XHR;
}

function ajaxPOST(url,params,func){
		// Perform a POST AJAX request to 'url'
        // params is the post params string
		// func is the callback
	
		var XHR = get_XHR();
        
        //AJAX POST REQUEST
        XHR.open("POST", url, true);
        XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        XHR.setRequestHeader("Content-length", params.length);
        XHR.setRequestHeader("Connection", "close");
        XHR.send(params);
        XHR.onreadystatechange = func;
}

function ajaxGET(url,func){
		// Perform a POST AJAX request to 'url'
		// func is the callback
		var XHR = get_XHR();
		
		XHR.open("GET",url,true);
		XHR.onreadystatechange = func;
}

function resultsReady() {
        //this function is called when the AJAX response is ready
        if(this.readyState == 4 && this.status == 200) {
                document.getElementById("results").innerHTML = this.responseText; //Display the response into the results div               
        }
}